package com.triones.api.controller.web;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.triones.api.entity.WordOrderDO;
import com.triones.api.entity.param.WordOrderParams;
import com.triones.api.entity.vo.CustomWordOrderVO;
import com.triones.api.service.WordOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 工单
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/wordOrder")
public class    WordOrderController extends BaseController {

    private final WordOrderService wordOrderService;

    /**
     * 工单列表（分页）
     */
    @SaCheckPermission("system:wordOrder:pageList")
    @GetMapping("/list")
    public TableDataInfo<CustomWordOrderVO> pageList(WordOrderParams wordOrderParams, PageQuery pageQuery) {
        return wordOrderService.pageList(wordOrderParams, pageQuery);
    }

    /**
     * 工单详情
     */
    @SaCheckPermission("system:wordOrder:query")
    @GetMapping("/{id}")
    public R<CustomWordOrderVO> getInfo(@PathVariable Long id) {
        return R.ok(wordOrderService.getInfo(id));
    }

    /**
     * 工单修改
     */
    @SaCheckPermission("system:wordOrder:edit")
    @Log(title = "工单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Void> edit(@Validated @RequestBody WordOrderDO dto) {
        return toAjax(wordOrderService.edit(dto));
    }

    /**
     * 工单删除
     */
    @SaCheckPermission("system:wordOrder:remove")
    @Log(title = "工单管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public R<Void> remove(@PathVariable Long id) {
        return toAjax(wordOrderService.sysRemove(id));
    }
}
